package org.orbis.communicate.rpc;

import org.msgpack.MessagePackObject;
import org.msgpack.object.ArrayType;

public interface PeerHandlerInterface{
	// Send a node chain.
	public ArrayType nodeList();

	// Registers node to chains.
	public boolean register(String IPaddr, int port);

	// Delete node.
	public void deleteNode(String nodeIP, int port);

	// get specified range of data.
	public ArrayType getData(int clusterID, long key);

	// determine data size ranged by specified hash, and prepare for sending
	// data.
	public int getDataSize(int clusterID, long key);

	// end to send data.
	public boolean endDataSend(long ID);

	// force to end sending data.
	public void forceStop(int ID);

	// delete data by ID.
	public void deleteContent(ArrayType deletePkg, int cluster);

	// return whether the node lives.
	public String isLive();

	// add specified content to index.
	public void indexContent(ArrayType content);

	// add specified term to index.
	public void indexTerm(ArrayType terms);

	// search specified term.
	public ArrayType searchTerm(ArrayType packed, int cluster);

	// get content by ID.
	public MessagePackObject getContent(long ID, int cluster);

	// get index list.
	public ArrayType getList(int ptrBlock, int ptrPoint, long IDfrom, int length);

	// get required information to participate node chain.
	public ArrayType getInfo();

	// calls to stop indexing (TODO: and change indexing bank to secondary)
	public void stopIndexing();

	// calls to resume indexing (TODO: change indexing bank to primary and merge
	// indices)
	public void resumeIndexing();

	// calls to take snapshot
	public void snapshot();

	// calls to make backup file
	public void backupLatest();
	
	// calls to take snapshot and backup latest entry
	public void revertLatest();

	// return index-queue length.
	public int getIndexQueue();

	// return search-queue length.
	public int getSearchQueue();

	// Synchronize timings to backup, living services
	public void synchronizeClock();
	
	// Suspend specified node
	public void suspend(String IPaddr, int port, long suspendTime, String reason);
	
	// Resume as specified node initially re-opens
	public void resume(String IPaddr, int port);
}
